package user;

import user.factory.AdminUserFactory;
import user.factory.IUserfactory;
import user.factory.NormalUserFactory;

/**
 * 该类只是在创建用户类时用来测试使用的,并没有参与项目实际的应用过程当中去
 */
public class UserManagement {

    public static void main(String[] args) {
        //创建工厂
        IUserfactory adminUserFactory = new AdminUserFactory();
        IUserfactory normalUserFactory = new NormalUserFactory();

        //创建管理员和普通用户实例
        User adminUser1 = adminUserFactory.createUSer("张三",1);
        User normalUser1 = normalUserFactory.createUSer("李四",2);
        User normalUser2 = normalUserFactory.createUSer("王五",3);

        //创建代理类实例来代理管理员和普通用户
        ProxyUser proxyUserAdmin1 = new ProxyUser(adminUser1);
        ProxyUser proxyUserNormal2 = new ProxyUser(normalUser1);
        ProxyUser proxyUserNormal3 = new ProxyUser(normalUser2);

        //用代理类为不同类型用户代理
      /* adminUser1.display();
         System.out.println("--------------------------------------");
         normalUser1.display(); */
        proxyUserNormal2.borrowBook();
        proxyUserNormal3.borrowBook();

    }

    public static void main1(String[] args) {
        IUserfactory adminUserFactory = new AdminUserFactory();
        User adminUser1 = adminUserFactory.createUSer("张三",1);

        IUserfactory normalUserFactory = new NormalUserFactory();
        User normalUser1 = normalUserFactory.createUSer("李四",2);
    }
}
